%config_sph从N=14开始是用球坐标表示的
function [config_sph, en] = create_config(config0)
    N =length(config0);
    d = 0.88;
    config = config0;
    config_sph = config0;
    r_min = 1.1; r_max = 2.3;
    theta_min = 0; theta_max = pi;
    phi_min = 0; phi_max = 2*pi;
    
    for i = 14:N
        while 1
            r = r_min + rand * (r_max - r_min);
            theta  = theta_min + rand * (theta_max - theta_min);
            phi = phi_min + rand * (phi_max - phi_min);
            x = r * sin(theta) * cos(phi);
            y = r * sin(theta) * sin(phi);
            z = r * cos(theta);

            new = [x,y,z];
            
            judge = 1;

            for j=1:(i-1)
                rj_vector = config{j} - new;
                rj_square = sum(rj_vector.^2);
                rj = sqrt(rj_square);
                if(rj < d)
                    judge = 0;
                    break
                end
            end

            if(judge == 1)
                config_sph{i} = [r,theta,phi];
                config{i} = new;
                break
            else

            end        
        end   
    end
    en = en_cal(config);

    return
end